package com.whub507.msgmanager.security.controller;

import com.whub507.msgmanager.common.ResResult;
import com.whub507.msgmanager.security.domain.User;
import com.whub507.msgmanager.security.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.CrossOrigin;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("/user")
@Api(value = "登录接口")
public class LoginController {
    @Resource
    UserService userService;

    @ApiOperation("登录")
    @GetMapping("/login")
    public ResResult<Boolean> login(String SessionToken ,String userName){
        List<String> auths=new ArrayList<>();
        User user=new User(userName,SessionToken,auths,1);
        userService.login(user);
        return ResResult.ok(Boolean.TRUE,"登录成功");
    }
}
